{layout name="layout" /}

<div class="Hui-article">
	<article class="cl pd-20">
		<form action="" method="post" class="form form-horizontal" id="form-set">
			{foreach $data as $val}
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">
					{$val.name}：</label>
				<div class="formControls col-xs-8 col-sm-3">
					<input type="text" class="input-text" id="{$val.field}" name="{$val.field}" value="{$val.value}" data-old="{$val.value}"
					    disabled="true">
				</div>
				<div class="formControls col-xs-8 col-sm-2">
					<button class="btn btn-primary radius modify" type="button" style="display:block;" onClick="modify(this, '{$val.field}')">修改</button>
					<button class="btn btn-success radius {$val.field} do_modify" type="button" style="display:none;" onClick="do_modify(this, '{$val.field}', '{$val.id}')">确定</button>
					<button class="btn btn-deefault radius {$val.field} do_modify" type="button" style="display:none;" onClick="cancle(this, '{$val.field}')">取消</button>
				</div>
			</div>
			{/foreach}
			<!-- <div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"></label>
				<div class="formControls col-xs-8 col-sm-4">
					<img src="{$logo.value}" id="img_thumb" alt="logo" style="width:200px; height: 120px;">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">网站logo:</label>
				<div class="formControls col-xs-8 col-sm-3">
					<input type="text" class="input-text" id="thumb" name="{$logo.field}" value="{$logo.value}" data-old="{$logo.value}"
					    disabled="true">
				</div>
				<div class="formControls col-xs-8 col-sm-2">
					<a href="javascript:;" class="btn btn-primary radius" onClick="addthumb()">
						<i class="Hui-iconfont">&#xe600;</i>更换logo</a>
				</div>
			</div> -->
		</form>
	</article>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
	function modify(obj, field) {
		$('.input-text').attr('disabled', true);
		$("#" + field).attr('disabled', false);
		$("#" + field).focus();
		$('.modify').css('display', 'inline');
		$('.do_modify').css('display', 'none');
		$("." + field).css('display', 'inline');
		$(obj).css('display', 'none');
	}

	function do_modify(obj, field, id) {
		var value = $("#" + field).val();

		$.post('modify', {
			'id': id,
			'field': field,
			'value': value
		}, function (data) {
			if (data.code == 2) {
				layer.msg(data.msg, {
					icon: 1,
					time: 1000
				});
				$("#" + field).attr('disabled', true);
				$("." + field).css('display', 'none');
				$(obj).prevAll(".btn-primary").css('display', 'inline');
			} else {
				layer.msg(data.msg, {
					icon: 5,
					time: 1000
				});
				return false;
			}
		}, 'json');
	}

	function cancle(obj, field) {
		var old = $("#" + field).data('old');
		$("#" + field).attr('disabled', true);
		$("#" + field).val(old);
		$("." + field).css('display', 'none');
		$(obj).prevAll(".btn-primary").css('display', 'inline');
	}

    //添加缩略图
    function addthumb() {
        layer.open({
            type: 2,
            area: ['700px', '500px'],
            fix: false, //不固定
            maxmin: true,
            shade: 0.4,
            title: '添加缩略图',
            content: '{:url("file_manager/addThumb")}'
        });
    }
</script>
<!--请在上方写此页面业务相关的脚本-->